import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { WingBlank } from 'antd-mobile'
import css from './index.module.scss'
import ErrorImage from '@/assets/images/404.png'
export default class ErrorDefault extends PureComponent {
    static propTypes = {
        renderError: PropTypes.func,
        showErrorImage: PropTypes.bool
    }

    static defaultProps = {
        showErrorImage: true
    }

    render() {
        const { showErrorImage, renderError, className } = this.props
        return (
            <WingBlank className={`${css['wrap']} ${className || ''}`}>
                { showErrorImage && <div className={css['content']}>
                    <img src={ErrorImage} alt="出错了"/>
                </div> 
                }
                {
                    renderError && <div className={css['tips']}>{renderError()}</div>
                }
                {
                    !renderError && <div className={css['tips']}>
                        <p>您访问的页面不见了/(ToT)/~~</p>
                    </div>
                }    
                { this.props.children }                                
            </WingBlank>
        )
    }
}